package com.social.controller;

import com.social.pojo.PageBean;
import com.social.pojo.Result;
import com.social.pojo.SysMenu;
import com.social.service.SysMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @BelongsProject: social
 * @BelongsPackage: com.social.controller
 * @Author: zhm
 * @CreateTime: 2022-11-15  10:57
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/sys/menu")
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @PostMapping("/list")
    public Result getAll(@Valid @RequestBody PageBean pageBean){
        return sysMenuService.findAll(pageBean);
    }

    @Transactional
    @DeleteMapping("/delete")
    public Result delete(@RequestBody Long[] ids){
        return sysMenuService.deleteByIds(ids);
    }

    @GetMapping("/listAll")
    public Result listAll(){
        return sysMenuService.listAll();
    }

    @PutMapping("/save")
    public Result save(@Valid @RequestBody SysMenu sysMenu){
        return sysMenuService.add(sysMenu);
    }

}
